package zhieasy.cn.xpu_helper.controller.course;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import zhieasy.cn.common.form.GetCourseForm;
import zhieasy.cn.common.utils.ResultVOUtil;
import zhieasy.cn.common.utils.result.ResultUtils;
import zhieasy.cn.common.vo.ResultVO;
import zhieasy.cn.model.common.WechatUser;
import zhieasy.cn.model.course.CourseInfo;
import zhieasy.cn.service.course.GetCourseService;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author DaHang
 * @date 2020/8/21 23:17
 */
@Slf4j
@Api(tags = "课表模块，对课程操作接口",value = "/course")
@RestController
@RequestMapping("/course")
public class CourseController {
    @Resource
    private GetCourseService getCourseService;

    /**
     * 获取课表之前先获得SessionCode与验证码图片
     */
    @GetMapping("/before-course")
    public ResultVO beforeCourse(){
        String wxOpenId = WechatUser.getWechatUserOpenIdFromSecurityContext();
        String name = getCourseService.getAuthCodeImage(wxOpenId);
        return ResultVOUtil.success(name);
    }

    @ApiOperation(value = "/getCourseFromOffice" , notes = "通过教务处获取课程表", httpMethod = "POST")
    @PostMapping(value = "/getCourseFromOffice")
    public ResultVO getCourseFromOffice(@RequestBody GetCourseForm getCourseForm){
        String wxOpenId = WechatUser.getWechatUserOpenIdFromSecurityContext();
        return ResultUtils.success(getCourseService.getCourseInfo(getCourseForm, wxOpenId));
    }

    @ApiOperation(value = "/addCourse" , notes = "手动添加课程")
    @RequestMapping(value = "/addCourse", method = RequestMethod.POST)
    public ResultVO addCourseByManual(@RequestBody CourseInfo courseInfo){

        return ResultUtils.success();
    }

    @ApiOperation(value = "/deleteCourse", notes = "删除课程")
    @RequestMapping(value = "/deleteCourse", method = RequestMethod.POST)
    public ResultVO deleteCourse(@RequestBody CourseInfo courseInfo){

        return ResultUtils.success();
    }

    @ApiOperation(value = "/chooseWeekCourses" , notes = "查看某一个周的课程")
    @RequestMapping(value = "/chooseWeekCourses", method = RequestMethod.GET)
    public ResultVO chooseWeekCourses(int week){

        return ResultUtils.success();
    }

    @ApiOperation(value = "/getCourseOnOneDay" , notes = "获取某一天的课程")
    @RequestMapping(value = "/getCourseOnOneDay", method = RequestMethod.GET)
    public ResultVO getCourseOnOneDay(Date date){

        return ResultUtils.success();
    }
}
